package top.caoayu.base.mapper;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import java.util.Collection;
import java.util.List;

import org.apache.ibatis.annotations.Param;

import top.caoayu.base.entity.SysRole;
import top.caoayu.base.entity.SysUser;

public interface SysUserMapper extends com.baomidou.mybatisplus.core.mapper.BaseMapper<SysUser> {
    SysUser selectById(@Param("id") Long id);

    List<SysRole> selectRolesByUserId(@Param("userId") Long userId);

    int insertList(@Param("list") List<SysUser> list);

    @Override
    int insert(SysUser entity);

    int insertUseSelectKey(SysUser entity);

    int insertUseSequence(SysUser entity);

    int updateById(@Param("updated") SysUser updated, @Param("id") Long id);

    int deleteById(@Param("id") Long id);

    List<SysRole> selectRolesByUserIdAndRoleEnabled(@Param("userId") Long userId, @Param("enabled") Integer enabled);

    List<SysUser> selectByUserNameLikeOrUserEmailLike(@Param("likeUserName") String likeUserName, @Param("likeUserEmail") String likeUserEmail);

    IPage<SysUser> selectByAll(IPage<SysUser> page, SysUser sysUser);

    List<SysUser> selectByUser(SysUser sysUser);

    int updateByIdSelective(SysUser sysUser);

    int insertSelective(SysUser sysUser);


    IPage<SysUser> selectAllUserAndRoles(@Param("page") IPage<SysUser> page);

    List<SysUser> selectAllUserAndRolesAndPrivileges();

    SysUser selectUserRoleAndPrivilegeById(@Param("id") Long id);


    default int deleteByIdIn(Collection<Long> idCollection) {
        LambdaQueryWrapper<SysUser> myQuery = Wrappers.lambdaQuery(SysUser.class);
        myQuery.in(SysUser::getId, idCollection);
        return delete(myQuery);
    }

    IPage<SysUser> selectByIdIn(IPage<SysUser> page, @Param("idCollection")Collection<Long> idCollection);


    List<SysUser> selectAll();



}